package com.example.demo.controller;

import com.example.demo.DTO.userDTO;
import com.example.demo.dao.order;
import com.example.demo.dao.user;
import com.example.demo.service.orderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "*")
@RestController
public class orderController {
    @Autowired
    private orderService orderService;
    @PostMapping("/addOrder")//用户注册
    public order addNewOrder(@RequestBody order order) {
        System.out.println(order);
        return orderService.addOrder(order);
    }
    @PostMapping("/getOrderByBuyName")
    public List<order> getOrderByBuyNameAndOrderState(@RequestBody order order) {
        return orderService.getOrderByBuyName(order.getBuyName());
    }
    @PostMapping("/getOrderByBusinessName")
    public List<order> getOrderByBusinessName(@RequestBody order order) {
        return orderService.getOrderByBusinessName(order.getBusinessName());
    }
    @PostMapping("/getOrderById")
    public order getOrderById(@RequestBody order order) {
        return orderService.getOrderById(order.getOrderformId());
    }
    @PostMapping("/updOrderState")
    public order updOrderState(@RequestBody order order) {
        return orderService.updOrderState(order.getOrderformId(),order.getOrderformState());
    }
    @PostMapping("/delOrderById")
    public void delOrderById(@RequestBody order order){
        orderService.delOrderById(order.getOrderformId());
    }
}